import Vue from 'vue';
import App from './App.vue';

import Vuex from 'vuex';
Vue.use(Vuex);

import router from './router/router';

// 上映日期过滤器
Vue.filter('fliterDate', function(val) {
    var time = new Date(val);
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var syrq = m + '月' + d + '日上映';
    return syrq;
})

// 时间戳转星期几

Vue.filter('nbl', function(val) {
    var date = new Date(val);
    var week = "";
    switch (date.getDay()) {
        case 0:
            week = "星期天";
            break
        case 1:
            week = "星期一";
            break
        case 2:
            week = "星期二";
            break
        case 3:
            week = "星期三";
            break
        case 4:
            week = "星期四";
            break
        case 5:
            week = "星期五";
            break
        case 6:
            week = "星期六";
            break
    }
    return week;
})

// 实例化一个store
var store = new Vuex.Store({
    state: {
        title: '卖座电影'
    },
    mutations: {
        chengeTitle: function(state, nb) {
            state.title = nb;
        }
    }
})

new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
})